package com.ruoyi.biz.service.impl;

import com.ruoyi.biz.dto.LotteryPrizeDTO;
import com.ruoyi.biz.entity.LotteryDO;
import com.ruoyi.biz.entity.LotteryPrizeDO;
import com.ruoyi.biz.mapper.LotteryPrizeDAO;
import com.ruoyi.biz.service.LotteryPrizeService;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class LotteryPrizeServiceImpl implements LotteryPrizeService {

    @Resource
    LotteryPrizeDAO lotteryPrizeDAO;

    @Override
    public List<LotteryPrizeDO> queryList(LotteryPrizeDTO lotteryPrizeDTO) {
        LotteryPrizeDO lotteryPrizeDO = new LotteryPrizeDO();
        BeanUtils.copyBeanProp(lotteryPrizeDO, lotteryPrizeDTO);
        lotteryPrizeDO.setValiFlag("1");
        return lotteryPrizeDAO.queryList(lotteryPrizeDO);
    }

    @Override
    public int insertLotteryPrize(LotteryPrizeDTO lotteryPrizeDTO) {
        LotteryPrizeDO lotteryPrizeDO = new LotteryPrizeDO();
        BeanUtils.copyBeanProp(lotteryPrizeDO, lotteryPrizeDTO);
        lotteryPrizeDO.setLotteryPrizeId(IdUtils.simpleUUID().toUpperCase());
        lotteryPrizeDO.setValiFlag("1");
        lotteryPrizeDO.setUpdtTime(new Date());
        return lotteryPrizeDAO.insert(lotteryPrizeDO);
    }

    @Override
    public LotteryPrizeDTO queryById(String lotteryPrizeId) {
        LotteryPrizeDO lotteryPrizeDO = lotteryPrizeDAO.queryById(lotteryPrizeId);
        LotteryPrizeDTO lotteryPrizeDTO = new LotteryPrizeDTO();
        BeanUtils.copyBeanProp(lotteryPrizeDTO, lotteryPrizeDO);
        return lotteryPrizeDTO;
    }

    @Override
    public int deleteLotteryPrize(String ids) {
        LotteryPrizeDO lotteryPrizeDO = new LotteryPrizeDO();
        lotteryPrizeDO.setUpdtTime(new Date());
        lotteryPrizeDO.setLotteryPrizeId(ids);
        lotteryPrizeDO.setValiFlag("0");
        return lotteryPrizeDAO.update(lotteryPrizeDO);
    }

    @Override
    public int updateLotteryPrize(LotteryPrizeDTO lotteryPrizeDTO) {
        LotteryPrizeDO lotteryPrizeDO = new LotteryPrizeDO();
        BeanUtils.copyBeanProp(lotteryPrizeDO, lotteryPrizeDTO);
        lotteryPrizeDO.setUpdtTime(new Date());
        return lotteryPrizeDAO.update(lotteryPrizeDO);
    }


}
